home *** CD-ROM | disk | FTP | other *** search
/ Commodore Free 22 / Commodore_Free_Issue_22_2008_Commodore_Computer_Club.d64 / t.b guide 7.1 < prev    next >
Text File  |  2023-02-26  |  11KB  |  376 lines

  1. u
  2.  
  3. In the Beginning CHAPTER 7 SECTION 1
  4. \Lord Ronin from Q-Link\
  5.  
  6.  
  7. Welcome to the second side of a 1541
  8. disk. Well, at least on the original
  9. creation. <G>
  10.  
  11. FOR NEXT LOOPS
  12. --------------
  13. FOR NEXT LOOPS are what the Commodore
  14. user book has for the next piece of
  15. information. By this time I suspect
  16. that you have some idea that what the
  17. manual presents is not a full
  18. programming course, Only a taster of
  19. the subject. Yet the manual is an
  20. attempt to make the computer a
  21. friendly, rather than a scary thing.
  22. Each of these parts really deserve
  23. full chapters in programming manuals.
  24.  
  25. Getting that information out of the
  26. way. Here is what the Commodore user
  27. book has for you to type in,
  28.  
  29. new <press return, clears the memory>
  30.  
  31. 10 FORCT=1TO5
  32. 20 ?"COMMODORE 64"
  33. 30 NEXTCT
  34.  
  35. Like a nagging yiddish momma, remember
  36. to press return after typing in a
  37. line. Forgetting to press Return is a
  38. common fault that we all share, and
  39. all forget to do from time to time.
  40. Forgetting to press return is on
  41. annoying user error  to find that the
  42. line didn't take, when you are
  43. debugging 6 pages of a type in
  44. programme.
  45.  
  46. Yeah when you run this programme, it
  47. does the same thing as the IF THEN
  48. Just that it is smaller. Lets go over
  49. it a bit. Line 10, right they are
  50. called line numbers. Although I have a
  51. programming book collection that isn't
  52. American English that calls them line
  53. labels. Right back on topic, Line 10
  54. says the same thing that three lines
  55. in the IF THEN programme we did
  56. recently. Says that  "C" is going to
  57. be from 1 to 5. Line 20 says that the
  58. C= is to print that word line. Line 30
  59. says to do the next ct. Looping from
  60. line 10 back through for the 5 prints
  61.  
  62. A bit of a pause here, I dig that this
  63. is all strange and new and to be
  64. polite <a rarity for me> odd for you,
  65. these commands and typing in the
  66. stuff. Alien as you see it for the
  67. first time. Personally I was scared to
  68. type any of this into the computer,
  69. yet this is the stuff from that manual
  70. that came in the box with the C=64 PC.
  71. Pretty much everyone that uses, used,
  72. and programmes; then as well as now,
  73. started with to learn how to use the
  74. machine. Thankfully this isn't a
  75. series on how to programme, I am not
  76. that good. Despite my vanity and ego.
  77. Here, when you type in and run the
  78. programmes, You are doing the same as
  79. a guy 25+ years ago did. Feeling the
  80. same things as he felt, across the
  81. years. Out of the philosophic musings
  82. and lets get back to the programming
  83. stuff. 
  84.  
  85. What the manual doesn't say is that a
  86. FOR NEXT loop could be used for a
  87. timer in a programme. 100 for fz = 1
  88. to 250 : next fz. If I wrote that
  89. correctly from memory. This will delay
  90. the programme for a short amount of
  91. time, then the next line of the
  92. programme will happen. Mainly I have
  93. used this as a delay in my little
  94. intro screens. I mean that I have a
  95. bit of text on the screen, done with
  96. that print statement, this will sit
  97. there for a time and then another
  98. thing will pop up, Like an entire new
  99. screen. That may sound like a big
  100. thing, Only because you haven't done
  101. it yet, and I write it vague enough to
  102. make it sound great, When in reality
  103. it is just a few steps past what is in
  104. this manual.
  105.  
  106. Here is the next thing they have for a
  107. FOR NEXT.
  108.  
  109. NEW <RETURN>
  110.  
  111. 10 FORNB=1TO10 STEP.5
  112. 20 ?NB,
  113. 30 NEXTNB
  114.  
  115. Tearing this apart. Before or after
  116. you have rU (run) it. Did the new
  117. part. Then declare on line 10 the
  118. variable will be "nb". I think that
  119. they did that to suggest Number.
  120. Saying that it is going to be starting
  121. at 1 and ending at 10. That is sort of
  122. familiar to you from the previous
  123. stuff. But what the smeg is "step .5" 
  124.  
  125. Step is just what it says, a step,
  126. sort of like a step in walking, or a
  127. step in a set of stairs, One thing at
  128. a time. You don't need to tell the
  129. C=64 PC to go forward in the steps, If
  130. it is just one full step. If you want
  131. to run the programme above without the
  132. .5 part, Then it will act as if you
  133. had said "step 1". Gonna come back to
  134. that in a bit.
  135.  
  136. Next line tells it to print the nb
  137. variable, Last line tells it to go to
  138. the next nb variable. As you can see
  139. from the last few examples of
  140. variables, the value of the variable,
  141. or less techy said, what is in the
  142. variable, is changing each time
  143. through the programme. Note in the
  144. above one there is that comma.
  145. Explaining why there are 4 columns of
  146. printout on the screen. All this
  147. little thing does is count from 1 to
  148. 10, pretty much seen in that first
  149. line. Difference is that it is doing
  150. it in that .5. OK if you haven't run
  151. the programme, it starts off as 1 1.5
  152. 2 2.5 and so on until it reaches 10.
  153. Step .5 is the way its was told to
  154. count, Like I said above. If you
  155. remove that "step .5" it will count by
  156. ones. In fact if you want it to count
  157. by ones in a forward direction, you
  158. don't even need to put in the step
  159. section. If you are in an experimental
  160. mood, Then try changing the "step .5"
  161. to "step -1". Try it as a "step 2" or
  162. a "step 5", See how it works. Well the
  163. step -1 won't work, you should see
  164. something like ?syntax error line 10.
  165. Why? Kind of hard to count from a low
  166. positive number like 1, Up to a high
  167. positive number like 10, When you are
  168. counting in negative numbers <VBG>.
  169. Just change it from 1 to 10, over to
  170. 10 to 1 to make it work in line 10.
  171.  
  172. ADVANCED BASIC
  173. --------------
  174. Well we have made it to page 41,
  175. titled Advanced Basic. Compared to
  176. other books that I have seen. The
  177. commands may be advanced, but the
  178. lessons are not.
  179.  
  180. First thing to type in is this little
  181. animation programme, right there will
  182. be some sort of simple animation on
  183. the screen. Because the writing
  184. programme that I am using doesn't have
  185. the full character set. I am altering
  186. this programme a bit. Type it in and
  187. give it a run, I'll explain some
  188. things about it afterwards.
  189.  
  190. NEW <clears remember?>
  191.  
  192. 10 rem bouncing ball
  193. 20 ?"<clear/home>" <they want you to
  194. type the line number, the print
  195. command, the first quote, then a
  196. shifted clear home key, followed by
  197. ending the quote.>
  198.  
  199.  
  200.  
  201. 25 FOR X=1TO10:?"<DO ONE CURSOR
  202.  DOWN>":NEXT
  203. 30 FORBL=1TO40
  204. 40 ?" *<DO A CURSOR LEFT>";:
  205. 50 FOR TM=1TO5
  206. 60 NEXT TM
  207. 70 NEXT BL
  208. 75 REM MOVES BALL RIGHT TO LEFT
  209. 80 FOR BL = 40TO1 STEP -1
  210. 90 ?" <CURSOR LEFT><CURSOR LEFT> *
  211.  <CURSOR LEFT>";
  212. 100 FOR TM=1TO5
  213. 110 NEXT TM
  214. 120 NEXT BL
  215. 130 GOTO20
  216.  
  217. Scary isnt it? Yet there are some
  218. things here that we have already
  219. covered in the previous parts. If I
  220. typed this correctly, and you entered
  221. it correctly, there should be a *
  222. symbol that is about 20 lines down on
  223. the screen and goes from left to
  224. right, then right to left. Actual
  225. programme uses the shifted Q to get
  226. that filled in circle or ball graphic.
  227. We are going to tear this apart,
  228. Because there are some points to be
  229. made which may have thrown off your
  230. typing it in.
  231.  
  232. Line 10 starts off with the term REM,
  233. this is short for REMark. When the 64
  234. PC sees that in a programme, it is
  235. lazy and doesn't want to read remarks,
  236. so it acts as if it isn't there at
  237. all. This is a way for a programmer to
  238. insert information in the programme
  239. for others to see and work upon. I
  240. have seen it in menu programmes, A way
  241. to tell the user the how and what.
  242. Also seen it in BBS games, breaking
  243. the parts of the programme down for
  244. editing or fixing, Thats the good
  245. part. The bad part is that it also
  246. eats up memory space.
  247.  
  248. Line 20 I had to add explanation. You
  249. already have the print statement; know
  250. about the fact that what is in quotes
  251. is what you are going to have printed
  252. to the screen. Notice that when you
  253. did the quote and then the shifted
  254. clear/home keys there was a symbol
  255. that appeared. That is the symbol for
  256. that shifted clear home, Generally it
  257. is called just clear home; When not
  258. shifted it is called clear.
  259.  
  260. Line 25 is wrong. Yuppers it is wrong
  261. in the book, in all 27 copies of the
  262. book that I have, This is written
  263. incorrectly! Shocked that I contradict
  264. the writers of the book? Well there is
  265. another line coming up that I will say
  266. is wrong as well. Look at the line, it
  267. says that X=1to10. So you know that
  268. there is a 10 something in this line
  269. for the programme. Shows you the ":"
  270. symbol, in fact the book states, that
  271. indicates a new command. Now you make
  272. a quote and then do just one down
  273. cursor movement ending the quote. That
  274. will be another strange symbol to you.
  275. A : follows and the next command.
  276.  
  277. Well if you haven't run it yet. Give
  278. it a try, Ill be here to explain....
  279. OK see that it goes not 10 lines down,
  280. It goes 20 lines down, What the smeg?
  281. Many of the members of my users group
  282. have thought that they did it wrong
  283. and couldn't fix or see the problem,
  284. well here is a problem. Says to do 1
  285. to 10. Using a for next loop on that
  286. line, What you don't see is the fact
  287. that  : with a next as a command, adds
  288. another line as if you had said 1 to
  289. 20. There is a typo on this line. In
  290. order to fix it you need to type
  291. ?"<cursor down>";:next. The use of
  292. that ; will keep it on the same line
  293. of command. Basically it won't go down
  294. 20 lines just the 10 it is supposed to
  295. do for this programme.
  296.  
  297. Line 30 is another FOR NEXT loop, but
  298. only the FOR is on the line, BL is for
  299. the ball character. Says it is to be
  300. 1to40. This line is not wrong, run the
  301. programme, and take a hard look at the
  302. left and right side of the screen.
  303. Keep a careful eye out and you will
  304. see for a short moment, the graphic
  305. you used go up one line on one side
  306. and down one line on the other, Just
  307. one character. But it is going over
  308. the line on the screen, this is
  309. because of this line #80. OK scratch
  310. your head and wonder why, The
  311. programme is written so that you will
  312. the use it first. There are 40 columns
  313. on the screen, why is it doing 41 in
  314. each direction? The truth is that it
  315. isn't really it is doing 40 columns.
  316. Just that in my opinion, the author
  317. didn't want to go into a hard to
  318. understand the part about counting, in
  319. 1982ce. 
  320.  
  321. I mentioned this a little bit earlier,
  322. there are 40 columns; But remember
  323. that in computer things we will start
  324. the count at 0, not at 1. The 64 is
  325. doing what it was told, so no problem
  326. there. Well it means that you typed
  327. the programme in correctly from the
  328. book. Only that it was written to sort
  329. of re-enforce the 40 column part of
  330. the screen, i take it as a something
  331. that was glossed over for the time it
  332. was written. OK to correct this, we
  333. just need to change that 40 to 39 in
  334. the line. Can tell you that this shows
  335. two things about programming, one is
  336. start on some, but not all things, at
  337. 0. The other is well ah, just don't
  338. believe everything that is in a book
  339. or magazine to always be 100% correct,
  340. You may have to tweak with it a bit.
  341.  
  342. Line 40 may have caused you trouble in
  343. the way I wrote it, we have the print
  344. command, then the quote. Yes there is
  345. really a space before the * symbol,
  346. that needs to be in your line,
  347. Followed by one cursor left command.
  348.  
  349. Line 50 sets another FOR loop, here it
  350. is TM and it is 1 to 5. Think of this
  351. as Time and you will see it is the
  352. delay, as done in line 60, where it
  353. does the NEXT part, looping between
  354. those two lines 5 times before it goes
  355. to line 70. Line 70 will print on the
  356. screen the next variable called BL, Or
  357. the graphic symbol that you used.
  358.  
  359. Line 75 is just another REMark,
  360. Indicating a new part of the
  361. programme, The area where the motion
  362. of the ball is reversed. Line 80 is
  363. the same as line 30 In that it is
  364. using the same variable label. Also
  365. that it is doing a FOR and it is doing
  366. that 40 column movement, change that
  367. 40 to 39 to keep it on one line. Note
  368. that it starts at 40 and goes to 1,
  369. using that step thing at a -1 that
  370. moves the gfx from the right to the
  371. left.
  372.  
  373.        Continued in Section 2
  374.  
  375.  
  376.